/**
 * JungoMobileWeb
 * LoginDaoImpl.java
 * 
 * Copyright 2013 Teachizen
 * Written by cloudstick
 *	2013. 7. 26. first written.
 *
 * note:
 */
package com.jungo.web.dao.impl;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.jungo.web.bean.User;
import com.jungo.web.dao.LoginDao;

/**
 * @author cloudstick
 *
 */
@Repository
public class LoginDaoImpl extends SqlSessionDaoSupport implements LoginDao {

	/* (non-Javadoc)
	 * @see com.jungo.web.dao.LoginDao#existUser(java.lang.String)
	 */
	@Override
	public boolean existUser(String userid) {
		if ( userid == null || "".equals(userid) ) return false;
		Integer count = getSqlSession().selectOne("LoginDao.existUser", userid);
		return ( count > 0 ) ? true : false;
	}

	/* (non-Javadoc)
	 * @see com.jungo.web.dao.LoginDao#getUser(java.lang.String)
	 */
	@Override
	public User getUser(String userid) {
		// TODO Auto-generated method stub
		if ( userid == null || "".equals(userid) ) return null;
		return getSqlSession().selectOne("LoginDao.getUser", userid);
	}

	/* (non-Javadoc)
	 * @see com.jungo.web.dao.LoginDao#setUser(com.jungo.web.bean.User)
	 */
	@Override
	public void setUser(User user) {
		// TODO Auto-generated method stub
		getSqlSession().insert("LoginDao.setUser", user);
	}

	/* (non-Javadoc)
	 * @see com.jungo.web.dao.LoginDao#existDeviceId(java.lang.String)
	 */
	@Override
	public boolean existDeviceId(String deviceId) {
		if ( deviceId == null || "".equals(deviceId) ) return false;
		Integer count = getSqlSession().selectOne("LoginDao.existDeviceId", deviceId);
		return ( count > 0 ) ? true : false;
	}

	/* (non-Javadoc)
	 * @see com.jungo.web.dao.LoginDao#updateRegistrationId(java.lang.String)
	 */
	@Override
	public void updateRegistrationId(User user) {
		getSqlSession().update("LoginDao.updateRegistrationId", user);
	}

}
